/*
struct TreeNode {
	int val;
	struct TreeNode *left;
	struct TreeNode *right;
	TreeNode(int x) :
			val(x), left(NULL), right(NULL) {
	}
};*/
class Solution {
public:
	TreeNode* head=nullptr,*pre=nullptr;
    TreeNode* Convert(TreeNode* pRootOfTree) {

        if(nullptr==pRootOfTree){

			return nullptr;
		}
		Convert(pRootOfTree->left);
		if(nullptr==pre){

			head=pRootOfTree;
			pre=head;
		}
		else{

			pre->right=pRootOfTree;
			pRootOfTree->left=pre;
			pre=pRootOfTree;
		}
		Convert(pRootOfTree->right);
		return head;
    }
};
